<template>
	<view>
		<view class="time-select">
			<text @click="show=true">选择时间 {{startDate || '开始时间'}}-{{endDate || '结束时间'}}</text>
		</view>
		<u-cell-group>
			<u-cell v-for="(item,index) in list" :key="index" :title="item.xxmc" :label="item.createTime" isLink
				@click="viewCheck(item)">
				<u-tag v-if="item.commitState === 0" slot="value" text="未提交" shape="circle"></u-tag>
			</u-cell>
		</u-cell-group>
		<u-calendar :show="show" mode="range" @confirm="confirm" @close="calendarClose"></u-calendar>
	</view>
</template>

<script>
	import {
		siteSupervisionList
	} from "@/api/supervise/index.js"
	export default {
		data() {
			return {
				show: false,
				startDate: "",
				endDate: "",
				list: []
			}
		},
		onLoad() {
			this.siteSupervisionList();
		},
		methods: {
			confirm(e) {
				this.startDate = e[0];
				this.endDate = e[1];
				this.calendarClose();
				this.siteSupervisionList();
			},
			calendarClose() {
				this.show = false;
			},
			siteSupervisionList() {
				siteSupervisionList(this.startDate, this.endDate).then(res => {
					if (res.status === 0) {
						this.list = res.list;
					}
				});
			},
			viewCheck(item) {
				const queryData = {
					activityId: item.activityId,
					schoolId: item.schoolId,
					schoolName: item.xxmc,
					commentId: item.commentId,
					createTime: item.createTime,
				}
				if (item.commitState === 0) {
					this.$tab.navigateTo("/pages/index/supervise/supervise-target?queryData=" + encodeURIComponent(JSON
						.stringify(queryData)));
				} else {
					this.$tab.navigateTo("/pages/index/viewRecords/records?queryData=" + encodeURIComponent(JSON
						.stringify(queryData)));
				}

			}
		}
	}
</script>

<style lang="scss" scoped>
	.time-select {
		height: 6vh;
		line-height: 6vh;
		background-color: #FAFAFA;
		padding: 0 10px;
	}

	.view-school {
		height: 12vh;
		padding: 0 10px;
		background-color: #FFFFFF;
	}
</style>